<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="node_modules/vue/dist/vue.js"></script>
    <script src="./vue-lazyload.js"></script>
    <script src="node_modules/axios/dist/axios.js"></script>
    <div id="app">
        <div class="box">
            <li v-for="img in imgs" :key="img">
                <img v-lazy="img" alt="">
            </li>
        </div>
    </div>
    <script>
        const loading = 'http://localhost:3000/images/1.gif'
        Vue.use(VueLazyload,{
            preLoad:1.3, // 默认窗口的 1.3倍
            loading
        });
        let vm = new Vue({
            el:'#app',
            data:{
                imgs:[]
            },
            created(){
                axios.get('http://localhost:3000/api/img').then(res=>{
                    this.imgs = res.data;
                })
            }
        })
    </script>

    <style>
        .box{
            width:300px;
            height:300px;
            overflow: scroll;
        }
        img{
            width: 100px;
            height:100px;
        }

    </style>
</body>
</html>